import shutil
from os import makedirs
from os.path import exists

from gevent import os

if __name__ == '__main__':
    dataPath = '/Users/victor/Pictures/data/'
    distPath = '/Users/victor/Pictures/人物年龄/'
    imageList = os.listdir(dataPath)
    for file in imageList:
        fileName = str(file)
        dirName = distPath + fileName[:fileName.find('_')]
        if not exists(dirName):
            makedirs(dirName)

        try:
            shutil.copy(dataPath + fileName, dirName + '/' + fileName)
        except:
            print("error" + fileName)
